﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
namespace Hermes.Web.Address
{
    public partial class Add : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
                       
        }

        		protected void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(this.txtContact.Text.Trim().Length==0)
			{
				strErr+="Contact不能为空！\\n";	
			}
			if(this.txtCompany.Text.Trim().Length==0)
			{
				strErr+="Company不能为空！\\n";	
			}
			if(this.txtStreet.Text.Trim().Length==0)
			{
				strErr+="Street不能为空！\\n";	
			}
			if(this.txtDistrict.Text.Trim().Length==0)
			{
				strErr+="District不能为空！\\n";	
			}
			if(this.txtCity.Text.Trim().Length==0)
			{
				strErr+="City不能为空！\\n";	
			}
			if(this.txtProvince.Text.Trim().Length==0)
			{
				strErr+="Province不能为空！\\n";	
			}
			if(this.txtPostcode.Text.Trim().Length==0)
			{
				strErr+="Postcode不能为空！\\n";	
			}
			if(this.txtCountry.Text.Trim().Length==0)
			{
				strErr+="Country不能为空！\\n";	
			}
			if(this.txtEmail.Text.Trim().Length==0)
			{
				strErr+="Email不能为空！\\n";	
			}
			if(this.txtMobile.Text.Trim().Length==0)
			{
				strErr+="Mobile不能为空！\\n";	
			}
			if(this.txtPhone.Text.Trim().Length==0)
			{
				strErr+="Phone不能为空！\\n";	
			}
			if(!PageValidate.IsDateTime(txtLastUpdate.Text))
			{
				strErr+="LastUpdate格式错误！\\n";	
			}
			if(!PageValidate.IsNumber(txtType.Text))
			{
				strErr+="Type格式错误！\\n";	
			}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			string Contact=this.txtContact.Text;
			string Company=this.txtCompany.Text;
			string Street=this.txtStreet.Text;
			string District=this.txtDistrict.Text;
			string City=this.txtCity.Text;
			string Province=this.txtProvince.Text;
			string Postcode=this.txtPostcode.Text;
			string Country=this.txtCountry.Text;
			string Email=this.txtEmail.Text;
			string Mobile=this.txtMobile.Text;
			string Phone=this.txtPhone.Text;
			DateTime LastUpdate=DateTime.Parse(this.txtLastUpdate.Text);
			int Type=int.Parse(this.txtType.Text);

			Hermes.Model.Address model=new Hermes.Model.Address();
			model.Contact=Contact;
			model.Company=Company;
			model.Street=Street;
			model.District=District;
			model.City=City;
			model.Province=Province;
			model.Postcode=Postcode;
			model.Country=Country;
			model.Email=Email;
			model.Mobile=Mobile;
			model.Phone=Phone;
			model.LastUpdate=LastUpdate;
			model.Type=Type;

			Hermes.BLL.Address bll=new Hermes.BLL.Address();
			bll.Add(model);
			Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功！","add.aspx");

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
